package com.kj.tms.common.bean.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@ComponentScan(basePackages = {"com.kj.tms.*.*"})
@EnableWebMvc
public class SwaggerConfig extends WebMvcConfigurationSupport {

	@Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("kuaishou", "k.com", "yangruidong@kuaishou.com");
        return new ApiInfo("快手税务系统前台API接口",//大标题 title
                "快手税务系统Api文档",//小标题
                "0.0.1",//版本
                "k.com",//termsOfServiceUrl
                contact,//作者
                "Kuaishou",//链接显示文字
                "k.com"//网站链接
        );
    }
//    @Bean
//    public Docket createRestApi() {
//
//        List<Parameter> pars = new ArrayList<>();
//        //添加授权token
//        ParameterBuilder tokenPar = new ParameterBuilder();
//        tokenPar.name("token").description("授权token 注：登录不需要填，只有post方式的接口必填").
//                modelRef(new ModelRef("string")).
//                parameterType("header").required(false).build();
//        pars.add(tokenPar.build());
//
//        return new Docket(DocumentationType.SWAGGER_2)
//                .select()
//                .paths(Predicates.not(PathSelectors.regex("/error.*")))
//                .build()
//                .globalOperationParameters(pars)
//                .apiInfo(apiInfo());
//    }
	  
}